<template>
  <div style="position: relative">
    <el-card>
      <!-- 卡片组件 面包屑-->
      <div style="margin-bottom: 5px">
        <!-- 面包屑导航区域 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>数据统计</el-breadcrumb-item>
          <el-breadcrumb-item>数据报表</el-breadcrumb-item>
        </el-breadcrumb>
        <div style="margin-top: 15px; width: 30%; margin-bottom: 5px"></div>
      </div>
      <!-- 1.echarts容器 -->
      <div id="myChart" :style="{ width: '1000px', height: '500px' }"></div>
    </el-card>
  </div>
</template>

<script>
import { ReportsAPI } from "@/api/index";
// import * as echarts from "echarts";
// 2.导入
let echarts = require("echarts");
export default {
  data() {
    return {};
  },
  mounted() {
    this.useEchart();
  },
  methods: {
    async useEchart() {
      // 3.导出的echarts对象初始化
      let myChart = echarts.init(document.getElementById("myChart"));
      // 配置用的表格数据
      const res = await ReportsAPI();
      let option2 = res.data.data;
      console.log(option2);
      let option1 = {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: { type: "value" },
        series: [
          {
            lineStyle: {
              normal: {
                // color: "green",
                width: 10,
                type: "dashed",
              },
            },
          },
        ],
      };
      let option = { ...option1, ...option2 };
      // 4.使用
      myChart.setOption(option);
    },
  },
};
</script>

<style>
</style>